package cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.yudao.template.java.enums;

import cn.iocoder.yudao.framework.common.genCode.common.StringBuilderHandler;
import cn.iocoder.yudao.module.xiaoBizHandler.dal.dataobject.codegen.XiaoBizHandlerCodegenColumnDO;
import cn.iocoder.yudao.module.xiaoBizHandler.dal.dataobject.codegen.XiaoBizHandlerCodegenTableDO;
import cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.yudao.handler.PathHandler;
import cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.yudao.template.CodeGenTemplate;
import cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.GlobalBinding;
import cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.LocalBinding;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ErrorCode implements CodeGenTemplate {

    public String getPath(XiaoBizHandlerCodegenTableDO table, List<XiaoBizHandlerCodegenColumnDO> columns, GlobalBinding globalBinding, LocalBinding localBinding, XiaoBizHandlerCodegenColumnDO primaryColumn) {
        PathHandler pathHandler = PathHandler.builder()
                .table(table)
                .columns(columns)
                .globalBinding(globalBinding)
                .localBinding(localBinding)
                .primaryColumn(primaryColumn)
                .build();
        return pathHandler.javaModuleApiMainFilePath("enums/ErrorCodeConstants_手动操作");
    }


    public String render(XiaoBizHandlerCodegenTableDO table, List<XiaoBizHandlerCodegenColumnDO> columns, GlobalBinding globalBinding, LocalBinding localBinding, XiaoBizHandlerCodegenColumnDO primaryColumn) {
        StringBuilderHandler code = new StringBuilderHandler();
        code.apAndBl("// TODO 待办：请将下面的错误码复制到 yudao-module-" + table.getModuleName() + "-api 模块的 ErrorCodeConstants 类中。注意，请给“TODO 补充编号”设置一个错误码编号！！！");
        code.apAndBl("// ========== " + table.getClassComment() + " TODO 补充编号 ==========");
        code.apAndBl("ErrorCode "+ localBinding.getSimpleClassName_underlineCase().toUpperCase() +"_NOT_EXISTS = new ErrorCode(TODO 补充编号, \"" + table.getClassComment() + "不存在\");");
        return code.toString();
    }

}